#include <cstdio>
#include <map>
#include <vector>
#include <cstring>

using namespace std;

struct Node
{
    int x, y;
    Node( ) { }
    Node( int _x, int _y )
        : x( _x ), y( _y ) { }
};

vector<int> lx[ 100010 ], ly[ 100010 ];
map<int, int> mx, my;
int n, m, xn, yn;
bool visit[ 100010 ], vx[ 100010 ], vy[ 100010 ];
Node a[ 100010 ];

void init( )
{
    int i;
    memset( visit, 0, sizeof( visit ) );
    memset( vx, 0, sizeof( vx ) );
    memset( vy, 0, sizeof( vy ) );
    mx.clear( );
    my.clear( );
    xn = yn = 0;
    for ( i = 0; i < n; i++ )
    {
        lx[ i + 1 ].clear( );
        ly[ i + 1 ].clear( );
        scanf("%d%d", &a[ i ].x, &a[ i ].y);
        if ( !mx[ a[ i ].x ] )
            mx[ a[ i ].x ] = ++xn;
        if ( !my[ a[ i ].y ] )
            my[ a[ i ].y ] = ++yn;
        lx[ mx[ a[ i ].x ] ].push_back( i );
        ly[ my[ a[ i ].y ] ].push_back( i );
    }
}

void work( )
{
    int i, j, c, d, t, ret;
    for ( i = 0; i < m; i++ )
    {
        scanf("%d%d", &c, &d);
        ret = 0;
        if ( c )
        {
            t = my[ d ];
            if ( t && !vy[ t ] )
            {
                vy[ t ] = true;
                for ( j = 0; j < ly[ t ].size( ); j++ )
                {
                    ret += !visit[ ly[ t ][ j ] ];
                    visit[ ly[ t ][ j ] ] = true;
                }
            }
        }
        else
        {
            t = mx[ d ];
            if ( t && !vx[ t ] )
            {
                vx[ t ] = true;
                for ( j = 0; j < lx[ t ].size( ); j++ )
                {
                    ret += !visit[ lx[ t ][ j ] ];
                    visit[ lx[ t ][ j ] ] = true;
                }
            }
        }
        printf("%d\n", ret);
    }
    puts("");
}

int main( )
{
//    freopen("in.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
    while ( scanf("%d%d", &n, &m) )
    {
        if ( n == 0 && m == 0 )
            break;
        init( );
        work( );
    }
    return 0;
}
